package it.sevenbits.view;

import java.io.IOException;
import java.util.ResourceBundle;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;

public class LogApp {

    private Logger log;
    ResourceBundle bundle = null;

    public LogApp() {

        log = Logger.getLogger(LogApp.class.getName());
        bundle = ResourceBundle.getBundle("it.sevenbits.view.logging");
    }

    public void logMethod(String error) {

        try {
            LogManager.getLogManager().readConfiguration(
                LogApp.class.getResourceAsStream("logging.properties"));
            FileHandler fh = new FileHandler(
                bundle.getString("java.util.logging.FileHandler.pattern"));
            log.addHandler(fh);
            log.log(Level.SEVERE, error);
        } catch (IOException e) {
            System.err.println("Could not setup logger config" + e);
        }
    }
}